<template>
    <div class="login-container">
        <el-form ref="loginForm" class="login-form" auto-complete="on" label-position="left">

            <div class="title-container">
                <h3 class="login_title">登录</h3>
            </div>

            <el-form-item prop="username">
                <span class="svg-container">
                    <!-- <svg-icon icon-class="user" /> -->
                    <i class="el-icon-user"></i>
                </span>
                <el-input ref="username" size="mini" v-model="loginForm.username" placeholder="手机号、用户名" name="username" type="text"
                    tabindex="1" auto-complete="on" />
            </el-form-item>

            <el-form-item prop="password">
                <span class="svg-container">
                    <i class="iconfont el-icon-mima"></i>
                </span>
                <el-input ref="password"  v-model="loginForm.password" placeholder="密码" name="password" type="password"
                    tabindex="2" auto-complete="on" />
                <span class="show-pwd"></span>
            </el-form-item>

            <el-button type="primary" @click.native.prevent="handleLogins" style="width:100%;margin-bottom:30px;">登录
            </el-button>

            <div class="tips">
                <span style="margin-right:20px;">username: admin</span>
                <span> password: 123456</span>
            </div>

        </el-form>
    </div>
</template>


<script>
// import { mapState } from 'vuex'

export default {
    data() {
        return {
            loginForm: {
                username: 'admin',
                password: '12345678',
            }
        };
    },
    computed: {

    },
    methods: {
        handleLogins() {
            this.$store.dispatch('login/handleLogin', this.loginForm).then((res) => {
                console.log(res)
                if (res.code == 1) {
                    this.$router.push({ path: '/' });
                }
            })

        }
    }
}
</script>



<style lang="less" >
/* 修复input 背景不协调 和光标变色 */
/* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */

@bg: #283443;
@light_gray: #283443;
@cursor: #283443;

// @supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
//     .login-container .el-input input {
//         color: $cursor;
//     }
// }

/* reset element-ui css */
.login-container {
    height: 100vh;
    background-image: url("../../assets/image/loginbg.jpg");
    background-size: 100% 100%;



    .el-input {
        display: inline-block;
        height: 47px;
        width: 85%;

        input {
            background: transparent;
            border: 0px;
            -webkit-appearance: none;
            border-radius: 0px;
            padding: 12px 5px 12px 15px;
            color: @light_gray;
            height: 47px;
            caret-color: @cursor;

            &:-webkit-autofill {
                box-shadow: 0 0 0px 1000px @bg inset !important;
                -webkit-text-fill-color: @cursor  !important;
            }
        }
    }

    .el-form-item {
        border: 1px solid rgba(255, 255, 255, 0.1);
        // background: rgba(0, 0, 0, 0.1);
        border-radius: 5px;
        color: #454545;
        border: 1px solid #e3e3e3;
    }
}
</style>
    
    <style lang="less" scoped>
@bg: #2d3a4b;
@dark_gray: #889aa4;
@light_gray: #303133;

.login-container {
    min-height: 100%;
    width: 100%;
    background-color: @bg;
    overflow: hidden;

    .login-form {
        position: relative;      
        margin: 0 auto;
        overflow: hidden;
        width: 340px ;
        max-width: 100%;
        padding: 45px 35px 0;      
        background: #fff;
        height: 340px;
        top: 28%;
        margin-top:-50px;
        border-radius: 7px;
    }

    .tips {
        font-size: 14px;
        color: #fff;
        margin-bottom: 10px;

        span {
            &:first-of-type {
                margin-right: 16px;
            }
        }
    }

    .svg-container {
        padding: 6px 5px 6px 15px;
        color: @dark_gray;
        vertical-align: middle;
        width: 30px;
        display: inline-block;
    }

    .title-container {
        position: relative;

        .login_title {
            font-size: 26px;
            color: @light_gray;
            margin: 0px auto 40px auto;
            text-align: center;
            font-weight: bold;
        }
    }

    .show-pwd {
        position: absolute;
        right: 10px;
        top: 7px;
        font-size: 16px;
        color: @dark_gray;
        cursor: pointer;
        user-select: none;
    }
}
</style>